package io.renren.modules.user.controller;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import io.renren.common.utils.*;
import io.renren.modules.combat.entity.TFightInformationEntity;
import io.renren.modules.generator.entity.TTrainingEntity;
import io.renren.modules.statistis.statistisEntity;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.user.dao.TNomalDictionalDao;
import io.renren.modules.user.dao.TPeopleDao;
import io.renren.modules.user.dao.TPeopleDictionaryDao;
import io.renren.modules.user.dao.TPeopleFireDetachmentDao;
import io.renren.modules.user.entity.*;
import io.renren.modules.user.entity.form.PeopleEntityForm;
import io.renren.modules.user.entity.form.PeopleForm;
import io.renren.modules.user.entity.vo.*;
import io.renren.modules.user.service.TPeopleCopyService;
import io.renren.modules.user.service.TPeopleLogService;
import io.renren.modules.user.service.TPeopleService;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;


/**
 * 人员
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-02 10:30:00
 */
@RestController
@RequestMapping("/tpeople")
public class TPeopleController extends AbstractController {
    @Autowired
    private TPeopleService tPeopleService;
    @Autowired
    private TPeopleDao tPeopleDao;
    @Autowired
    private TPeopleCopyService tPeopleCopyService;
    @Autowired
    private TPeopleLogService tPeopleLogService;
    @Autowired
    private TPeopleFireDetachmentDao tPeopleFireDetachmentDao;
    @Autowired
    private TNomalDictionalDao tNomalDictionalDao;
    @Autowired
    private TPeopleDictionaryDao tPeopleDictionaryDao;


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("user:tpeople:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tPeopleService.queryPage(params);

        return R.ok().put("page", page);
    }



    /**
     * 信息
     */
    @RequestMapping("/info")
  //  @RequiresPermissions("user:tpeople:info")
    public R info(Integer id){
		TPeopleEntity tPeople = tPeopleService.getById(id);

        return R.ok().put("tPeople", tPeople);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("user:tpeople:save")
    public R save(@RequestBody TPeopleEntity tPeople){
		tPeopleService.save(tPeople);
        /*tPeople.setCreateTime(new Date());
        tPeople.setCreateUser(getUserId().intValue());
        tPeopleCopyService.saveTPeople(tPeople);*/
        return R.ok();
    }

    /*
    * 修改人员信息，保存到临时表
    * */
    @RequestMapping("/updatePeopleCopy")
    @RequiresPermissions("user:tpeople:updatepeople")
    public R updatePeopleCopy(@RequestBody TPeopleEntity tPeople){
        tPeopleCopyService.saveTPeople(tPeople);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
  //  @RequiresPermissions("user:tpeople:update")
    public R update(@RequestBody TPeopleEntity tPeople){
		//tPeopleService.updateById(tPeople);
		//记录日志
        tPeople.setCreateUser(getUserId().intValue());
        tPeopleLogService.saveLog(tPeople);
        return R.ok();
    }


    /*
    *  删除人员
    * */
    @RequestMapping("/updatePeople")
    @RequiresPermissions("user:tpeople:detele")
    public R updatePeople(@RequestBody TPeopleEntity tPeople){
        tPeopleService.updateById(tPeople);
       /* tPeople.setCreateUser(getUserId().intValue());
        tPeopleLogService.saveLog(tPeople);*/
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
  //  @RequiresPermissions("user:tpeople:delete")
    public R delete(@RequestBody Integer[] ids){
		tPeopleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /*
    * 人员分布图（消防员）
    * */
    @RequestMapping("/findPeopleList")
    public R findPeopleList(@RequestBody PeopleVo peopleVo){

        List<PeopleVo> peopleList = tPeopleService.findPeopleList(peopleVo.getDeptId(),peopleVo.getSquadron());
        return R.ok().put("data",peopleList);
    }

    /*
     * 人员分布图（专职消防员）
     * */
    @RequestMapping("/findPeopleZZList")
    public R findPeopleZZList(@RequestBody PeopleVo parentId){
        List<PeopleZZVo> peopleList = tPeopleService.findPeopleZZList(parentId.getDeptId(),parentId.getSquadron());
        return R.ok().put("data",peopleList);
    }
    /*
     * 中队人员分布图（专职消防员）
     * */
    @RequestMapping("/findPeopleZList")
    public R findPeopleZList(@RequestBody PeopleVo parentId){
        String zdeptId= parentId.getZdept();
        List<PeopleZZVo> peopleList = tPeopleService.findPeopleZList(parentId.getDeptId(),zdeptId);
        return R.ok().put("data",peopleList);
    }

    /*
     * 班组人员分布图（消防员）
     * */
    @RequestMapping("/findPeopleClassesList")
    public R findPeopleClassesList(Integer deptId){
        List<PeopleVo> peopleList = tPeopleService.findPeopleClassesList(deptId);
        return R.ok().put("data",peopleList);
    }

    /*
     * 班组人员分布图（专职消防员）
     * */
    @RequestMapping("/findPeopleClassesZZList")
    public R findPeopleClassesZZList(@RequestBody PeopleVo peopleVo){
        List<PeopleZZVo> peopleList = tPeopleService.findPeopleClassesZZList(Integer.parseInt(peopleVo.getDeptId()));
        return R.ok().put("data",peopleList);
    }

    /*
    *人员信息查询
    * */
    @RequestMapping("/peoplelist")
    @RequiresPermissions("user:tpeople:list")
    public R peoplelist(@RequestBody PeopleForm peopleEntityVo){
       String sql = this.doSql(peopleEntityVo.getPeopleEntityForms(),peopleEntityVo.getFlag());
        Map<String,Object> params=new HashMap<String,Object> ();
        String sqls=null;
        if(!sql.equals("")){
            String a=sql.substring(0,3);
            if("and".equals(a)){
                sqls = deleteAssignChar(sql, 0, 'a');
             String sa = deleteAssignChar(sqls, 1, 'a');
             String sb = deleteAssignChar(sa, 1, 'n');
                sqls = deleteAssignChar(sb, 1, 'd');
            }
            if("or ".equals(a)){
                sqls = deleteAssignChar(sql, 0, 'o');
             String sa = deleteAssignChar(sqls, 1, 'o');
                sqls = deleteAssignChar(sa, 1, 'r');
            }

            System.out.print(sqls);
        }
        params.put("sqls",sqls);
        params.put("page",peopleEntityVo.getPage());
        params.put("limit",peopleEntityVo.getLimit());
        params.put("name",peopleEntityVo.getName());
        params.put("detachment",peopleEntityVo.getDetachment());
        params.put("pdetachment",peopleEntityVo.getPdetachment());
       /* params.put("zname",peopleEntityVo.getLikeName());*/
        params.put("likeName",peopleEntityVo.getLikeName());
        params.put("peopleType",peopleEntityVo.getPeopleType());
        params.put("classes",peopleEntityVo.getClasses());
        params.put("title",peopleEntityVo.getTitle());
        params.put("num",peopleEntityVo.getNum());
        params.put("administration",peopleEntityVo.getAdministration());
        params.put("deptId",peopleEntityVo.getDeptId());
        params.put("zdeptId",peopleEntityVo.getZdeptId());
        params.put("contractType",peopleEntityVo.getContractType());
        params.put("contractYear",peopleEntityVo.getContractYear());
        params.put("userId",peopleEntityVo.getUserId());
        params.put("detachmentName",peopleEntityVo.getDetachmentName());
        params.put("classesName",peopleEntityVo.getClassesName());
        params.put("pid",peopleEntityVo.getPid());
        PageUtils page = tPeopleService.queryPageList(params);
        return R.ok().put("page", page);
    }


    public static String deleteAssignChar(String str, int on, char c){
        int count = 0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(i) == c){
                count++;
                if(count == on){
                    str = str.substring(0, i) + str.substring(i + 1);
                }
            }
        }
        return str;
    }

    /*
    *  上传图片
    *
    * */
    @RequestMapping("/upload")
    public R upload(MultipartFile[] file){
        R r = FileUpload.updateFile(file);
        return r;
    }

    /*
    *  历史人员查询
    * */
    @RequestMapping("/peopleHistory")
    public R peopleHistory(@RequestBody TPeopleEntity people) {
        Integer peopleType = people.getPeopleType();
        String deptId = people.getDept();
        String year = people.getYear();
        String squadron=people.getSquadron();
        List<PeopleHistoryVo> peopleHistoryVos = tPeopleService.peopleHistory(peopleType,deptId,year,squadron);
        return R.ok().put("data",peopleHistoryVos);
    }

    /*
     *  历史人员查询中队
     * */
    @RequestMapping("/peopleHistoryDept")
    public R peopleHistoryDept(@RequestBody TPeopleEntity people) {
        Integer peopleType = people.getPeopleType();
        String deptId = people.getDept();
        String year = people.getYear();
        String zdeptId = people.getZdept();
        List<PeopleHistoryVo> peopleHistoryVos = tPeopleService.peopleHistoryDept(peopleType,deptId,year,zdeptId);
        return R.ok().put("data",peopleHistoryVos);
    }

    /*
     *  历史人员查询班组
     * */
    @RequestMapping("/peopleHistoryClasses")
    public R peopleHistoryClasses(@RequestBody TPeopleEntity people) {
        Integer peopleType = people.getPeopleType();
        String deptId = people.getDept();
        String year = people.getYear();
        String classes = people.getClasses()+"";
        List<PeopleHistoryVo> peopleHistoryVos = tPeopleService.peopleHistoryClasses(peopleType,deptId,year);
        return R.ok().put("data",peopleHistoryVos);
    }
    /*
     *个人信息查询
     * */
    @RequestMapping("/findPeople")
   // @RequiresPermissions("user:tpeople:findPeople")
    public R findPeople(Integer peopleId){
        TPeopleEntity tPeople = tPeopleService.getById(peopleId);
        //查询工作经理
        List<TPeopleResumeEntity> peopleResumeList = tPeopleService.findPeopleResume(peopleId);
         //查询战斗经历
        List<TFightInformationEntity> fightList =tPeopleService.findFight(peopleId);
        //训练经历
        List<TTrainingEntity> peopleTTraining = tPeopleService.findPeopleTTraining(peopleId);
        return R.ok().put("people",tPeople).put("peopleResume",peopleResumeList).
                put("fightList",fightList).put("peopleTTraining",peopleTTraining);
    }


    /*
    * 人员审批
    * */
    @RequestMapping("/peoplApply")
    public R peoplApply(@RequestBody TPeopleEntity tPeople){
        R r = tPeopleService.peoplApply(tPeople);
        return r;
    }

    /*
    * 申请退出
    * */
    @RequestMapping("/updatePeopleOut")
    public R updatePeopleOut(@RequestBody TPeopleOutEntity tPeopleOutEntity){
        tPeopleService.updatePeopleOut(tPeopleOutEntity);
        return R.ok();
    }

    /*
    * 单位人员
    * */
    @RequestMapping("/peopledeptCount")
    public R peopledeptCount(@RequestBody TPeopleEntity tPeopleEntity){
        String deptId = tPeopleEntity.getDept();
        PeopleCountVo peopleCountVo = tPeopleService.peopledeptCount(deptId);

        return R.ok().put("data",peopleCountVo);
    }

    /*
    /*
     * 单位人员支队
     * */
    @RequestMapping("/peopledeptCount1")
    public R peopledeptCount1(@RequestBody TPeopleEntity tPeopleEntity){
        String deptId = tPeopleEntity.getDept();
        PeopleCountVo peopleCountVo = tPeopleService.peopledeptCount1(deptId);

        return R.ok().put("data",peopleCountVo);
    }

    /*
     * 单位人员组
     * */
    @RequestMapping("/peopledeptCount2")
    public R peopledeptCount2(@RequestBody TPeopleEntity tPeopleEntity){
        String deptId = tPeopleEntity.getDept();
        String classes = tPeopleEntity.getClasses()+"";
        PeopleCountVo peopleCountVo = tPeopleService.peopledeptCount2(deptId,classes);

        return R.ok().put("data",peopleCountVo);
    }


    /*
     * 中队人员分布图（消防员）
     * */
    @RequestMapping("/peopleListInfo")
    public R peopleListInfo(@RequestBody TPeopleEntity tPeopleEntity){
        String deptId = tPeopleEntity.getDept();
        String zdeptId = tPeopleEntity.getZdept();
        List<PeopleVo> peopleList = tPeopleService.peopleListInfo(deptId,zdeptId);
        return R.ok().put("data",peopleList);
    }

    /*
    * 人员导出
    * */
    @RequestMapping("/exportPeople")
   // @RequiresPermissions("user:tpeople:excel")
    public R exportPeoplxe(HttpServletResponse response,@RequestParam PeopleForm peopleEntityVo) throws IOException {
        String title = "人员信息";
        String[] rowsName=new String[46];  //标题
        rowsName[0]="序号";
        rowsName[1]="姓名";
        rowsName[2]="曾用名";
        rowsName[3]="身份证号码";
        rowsName[4]="性别";
        rowsName[5]="出生日期";
        rowsName[6]="籍贯";
        rowsName[7]="民族";
        rowsName[8]="入职时间";
        rowsName[9]="身高";
        rowsName[10]="血型";
        rowsName[11]="招录地";
        rowsName[12]="现户籍";
        rowsName[13]="手机号码";
        rowsName[14]="招录前户籍";
        rowsName[15]="个人邮箱";
        rowsName[16]="入职前工龄";
        rowsName[17]="消防证号";
        rowsName[18]="人员编号";
        rowsName[19]="支队";
        rowsName[20]="中队";
        rowsName[21]="合同期限";
        rowsName[22]="合同期限年";
        rowsName[23]="班组";
        rowsName[24]="家庭情况";
        rowsName[25]="专业岗位";
        rowsName[26]="岗位时间";
        rowsName[27]="行政职务";
        rowsName[28]="任职时间";
        rowsName[29]="消防衔级";
        rowsName[30]="衔级时间";
        rowsName[31]="政治面貌";
        rowsName[32]="入党时间";
        rowsName[33]="文化程度";
        rowsName[34]="独生子女";
        rowsName[35]="大学生士兵或直招";
        rowsName[36]="干部子女";
        rowsName[37]="户口类型";
        rowsName[38]="招录前户口类型";
        rowsName[39]="职务等级";
        rowsName[40]="职务年月";
        rowsName[41]="技术等级";
        rowsName[42]="技术年月";
        rowsName[43]="本单位工龄";
        rowsName[44]="总工龄";
        rowsName[45]="人员类型";
        System.out.println(rowsName);
        /*List<Map<String,Object>> mapList = tTrainingService.DcTTrainingMap(trainingEntity);
        Logger.getLogger("获取全部列表数据"+JSONArray.toJSON(voList));*/
        /*int a=0;
        rowsName= new String[peopleEntityVo.getMap().size()];
        for (Map.Entry<String, Object> entry : peopleEntityVo.getMap().entrySet()) {
            rowsName[a]=entry.getKey();
            a++;
        }*/

        /*String sql = this.doSql(peopleEntityVo.getPeopleEntityForms(),peopleEntityVo.getFlag());
        Map<String,Object> params=new HashMap<String,Object> ();
        params.put("sql",sql);
        params.put("likeName",peopleEntityVo.getLikeName());
        params.put("peopleType",peopleEntityVo.getPeopleType());
        params.put("classes",peopleEntityVo.getClasses());
        params.put("title",peopleEntityVo.getTitle());
        params.put("num",peopleEntityVo.getNum());
        params.put("deptId",peopleEntityVo.getDeptId());
        params.put("zdeptId",peopleEntityVo.getZdeptId());
        params.put("contractType",peopleEntityVo.getContractType());
        params.put("contractYear",peopleEntityVo.getContractYear());
        List<TPeopleEntity> tPeopleEntities = tPeopleDao.queryPageList(params);*/
        List<TPeopleEntity> tPeopleEntities = tPeopleDao.queryPageList2();
        ArrayList<Object[]> arrayList=new ArrayList<>();

        for( TPeopleEntity tPeopleEntity: tPeopleEntities){
            Object[] obj=new Object[rowsName.length];
            obj[0]="";
            obj[1]=tPeopleEntity.getName();
            obj[2]=tPeopleEntity.getOldName();
            obj[3]=tPeopleEntity.getIdcard();
            obj[4]=tPeopleEntity.getSex();
            obj[5]=tPeopleEntity.getBirthday();
            obj[6]=tPeopleEntity.getBround();
            obj[7]=tPeopleEntity.getMinName();
            obj[8]=tPeopleEntity.getDutytime();
            obj[9]=tPeopleEntity.getHight();
            obj[10]=tPeopleEntity.getBlood();
            obj[11]=tPeopleEntity.getInvitation();
            obj[12]=tPeopleEntity.getHousehold();
            obj[13]=tPeopleEntity.getCallPhone();
            obj[14]=tPeopleEntity.getInvitationHousehold();
            obj[15]=tPeopleEntity.getEmail();
            obj[16]=tPeopleEntity.getSeniorityHistory();
            obj[17]=tPeopleEntity.getWorkidcard();
            obj[18]=tPeopleEntity.getPeopleCode();
            obj[19]=tPeopleEntity.getPdetachment();
            obj[20]=tPeopleEntity.getDetachment();
            obj[21]=tPeopleEntity.getContractType();
            obj[22]=tPeopleEntity.getContractYear();
            obj[23]=tPeopleEntity.getClassesName();
            obj[24]=tPeopleEntity.getHomeType();
            obj[25]=tPeopleEntity.getGname();
            obj[26]=tPeopleEntity.getDutyPostTime();
            obj[27]=tPeopleEntity.getAdministration();
            obj[28]=tPeopleEntity.getAdministrationTime();
            obj[29]=tPeopleEntity.getPeopleName();
            obj[30]=tPeopleEntity.getTitleTime();
            obj[31]=tPeopleEntity.getPolitical();
            obj[32]=tPeopleEntity.getPoliTime();
            obj[33]=tPeopleEntity.getEducation();
            obj[34]=tPeopleEntity.getSolo();
            obj[35]=tPeopleEntity.getIsStudentSergeant();
            obj[36]=tPeopleEntity.getCadre();
            obj[37]=tPeopleEntity.getRegisterType();
            obj[38]=tPeopleEntity.getInvitationRegister();
            obj[39]=tPeopleEntity.getName7();
            obj[40]=tPeopleEntity.getFireClassTime();
            obj[41]=tPeopleEntity.getTecClass();
            obj[42]=tPeopleEntity.getTecClassTime();
            obj[43]=tPeopleEntity.getSeniorityNow();
            obj[44]=tPeopleEntity.getSeniorityTotal();
            obj[45]=tPeopleEntity.getPeopleType1();

            arrayList.add(obj);
        }

        try{
            ExportExcel1 ex = new ExportExcel1(title, rowsName, arrayList);
            ex.export();
        }catch(Exception e){
            System.out.println("Wrong!");
        }
        return R.ok();

    }

    /*
    * 人员导入
    * */
    ArrayList<TPeopleEntity> array=null;
    @RequestMapping("/importPeople")
    @RequiresPermissions("user:tpeople:import")
    public R importPeople(@Param("file") MultipartFile file) throws Exception {
        if(file ==null){
            return R.error("文件不能为空");
        }else{
            List<TPeopleVoEntity> arrayList=new LinkedList<>();
            InputStream inputStream = file.getInputStream();
            LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>();
            fieldMap.put("姓名", "name");
            fieldMap.put("曾用名", "oldName");
            fieldMap.put("身份证号码", "idcard");
            fieldMap.put("性别", "sex");
            fieldMap.put("出生日期", "birthday");
            fieldMap.put("籍贯", "bround");
            fieldMap.put("民族", "ethnic");
            fieldMap.put("入职时间", "dutytime");
            fieldMap.put("身高", "hight");
            fieldMap.put("血型", "blood");
            fieldMap.put("招录地", "invitation");
            fieldMap.put("现户籍", "household");
            fieldMap.put("手机号码", "callPhone");
            fieldMap.put("招录前户籍", "invitationHousehold");
            fieldMap.put("个人邮箱", "email");
            fieldMap.put("入职前工龄", "seniorityHistory");
            fieldMap.put("消防证号", "workidcard");
            fieldMap.put("人员编号", "peopleCode");
            fieldMap.put("支队", "zdept");
            fieldMap.put("中队", "dept");
            fieldMap.put("合同期限", "contractType");
            fieldMap.put("合同期限年", "contractYear");
            fieldMap.put("班组", "classes");
            fieldMap.put("家庭情况", "homeType");
            fieldMap.put("专业岗位", "dutyPost");
            fieldMap.put("岗位时间", "dutyPostTime");
            fieldMap.put("行政职务", "administration");
            fieldMap.put("任职时间", "administrationTime");
            fieldMap.put("消防衔级", "title");
            fieldMap.put("衔级时间", "titleTime");
            fieldMap.put("政治面貌", "political");
            fieldMap.put("入党时间", "poliTime");
            fieldMap.put("文化程度", "education");
            fieldMap.put("独生子女", "solo");
            fieldMap.put("大学生士兵或直招", "isStudentSergeant");
            fieldMap.put("干部子女", "cadre");
            fieldMap.put("户口类型", "registerType");
            fieldMap.put("招录前户口类型", "invitationRegister");
            fieldMap.put("职务等级", "firePostClass");
            fieldMap.put("职务年月", "fireClassTime");
            fieldMap.put("技术等级", "tecClass");
            fieldMap.put("技术年月", "tecClassTime");
            fieldMap.put("本单位工龄", "seniorityNow");
            fieldMap.put("总工龄", "seniorityTotal");
            fieldMap.put("人员类型", "peopleType");
            String[] uniqueFields = {};
            String sheetName = "Sheet1";
            arrayList= ExcelUtil.excelToList(inputStream, sheetName, TPeopleVoEntity.class, fieldMap, uniqueFields);
            array=new ArrayList();
            for(TPeopleVoEntity tPeopleEntity: arrayList){
                TPeopleEntity tPeople=new TPeopleEntity();
                 //查询所有的中队单位
                TPeopleFireDetachmentEntity fireDetachment = tPeopleFireDetachmentDao.findFireDetachment(tPeopleEntity.getDept());
                //查询所有的支队单位
                TPeopleFireDetachmentEntity fireDept = tPeopleFireDetachmentDao.findFireDetachment(tPeopleEntity.getZdept());
                //查询所有的民族
                TNomalDictionalEntity tNomalEntity = tNomalDictionalDao.findName(tPeopleEntity.getEthnic());
                //查询班组
                TPeopleDictionaryEntity dictionaryEntity = tPeopleDictionaryDao.listClass(tPeopleEntity.getClasses() + "",null);
                //查询专业岗位
                TPeopleDictionaryEntity dictionary = tPeopleDictionaryDao.listClass(tPeopleEntity.getDutyPost()+"","10010");
                //查询行政职务
                TPeopleDictionaryEntity dictionary1 = tPeopleDictionaryDao.listClass(tPeopleEntity.getAdministration()+"","10020");
                //查询消防衔级
                TPeopleDictionaryEntity dictionaryTitle = tPeopleDictionaryDao.listClass(tPeopleEntity.getTitle()+"",null);
                //查询职务等级
                TPeopleDictionaryEntity dictionaryPost = tPeopleDictionaryDao.listClass(tPeopleEntity.getFirePostClass()+"",null);

                tPeople.setName(tPeopleEntity.getName());
                tPeople.setOldName(tPeopleEntity.getOldName());
                tPeople.setIdcard(tPeopleEntity.getIdcard());
                tPeople.setSex(tPeopleEntity.getSex());
                tPeople.setBirthday(tPeopleEntity.getBirthday());
                tPeople.setBround(tPeopleEntity.getBround());
                tPeople.setEthnic(tNomalEntity.getId()+"");
                tPeople.setDutytime(tPeopleEntity.getDutytime());
                tPeople.setHight(tPeopleEntity.getHight());
                tPeople.setBlood(tPeopleEntity.getBlood());
                tPeople.setInvitation(tPeopleEntity.getInvitation());
                tPeople.setHousehold(tPeopleEntity.getHousehold());
                tPeople.setCallPhone(tPeopleEntity.getCallPhone());
                tPeople.setInvitationHousehold(tPeopleEntity.getInvitationHousehold());
                tPeople.setEmail(tPeopleEntity.getEmail());
                tPeople.setSeniorityHistory(tPeopleEntity.getSeniorityHistory());
                tPeople.setWorkidcard(tPeopleEntity.getWorkidcard());
                tPeople.setPeopleCode(tPeopleEntity.getPeopleCode());
                tPeople.setZdept(fireDept.getId()+"");
                tPeople.setDept(fireDetachment.getId()+"");
                tPeople.setContractType(tPeopleEntity.getContractType());
                tPeople.setContractYear(tPeopleEntity.getContractYear());
                tPeople.setClasses(dictionaryEntity.getId());
                tPeople.setHomeType(tPeopleEntity.getHomeType());
                tPeople.setDutyPost(dictionary.getId());
                tPeople.setDutyPostTime(tPeopleEntity.getDutyPostTime());
                tPeople.setAdministration(dictionary1.getId());
                tPeople.setAdministrationTime(tPeopleEntity.getAdministrationTime());
                tPeople.setTitle(dictionaryTitle.getId()+"");
                tPeople.setTitleTime(tPeopleEntity.getTitleTime());
                tPeople.setPolitical(tPeopleEntity.getPolitical());
                tPeople.setPoliTime(tPeopleEntity.getPoliTime());
                tPeople.setEducation(tPeopleEntity.getEducation());
                tPeople.setSolo(tPeopleEntity.getSolo());
                tPeople.setIsStudentSergeant(tPeopleEntity.getIsStudentSergeant());
                tPeople.setCadre(tPeopleEntity.getCadre());
                tPeople.setRegisterType(tPeopleEntity.getRegisterType());
                tPeople.setInvitationRegister(tPeopleEntity.getInvitationRegister());
                tPeople.setFirePostClass(dictionaryPost.getId());
                tPeople.setFirePostTime(tPeopleEntity.getFirePostTime());
                tPeople.setTecClass(tPeopleEntity.getTecClass());
                tPeople.setTecClassTime(tPeopleEntity.getTecClassTime());
                tPeople.setSeniorityNow(tPeopleEntity.getSeniorityNow());
                tPeople.setSeniorityTotal(tPeopleEntity.getSeniorityTotal());
                tPeople.setPeopleType(tPeopleEntity.getPeopleType());

                array.add(tPeople);
            }
            //tPeopleService.saveBatch(array);

        }
        return R.ok().put("array",array);
    }

    /*
   /*
    * 人员导入  保存
    * */
    @RequestMapping("/saveArray")
    public R saveArray(){
        if(array==null){
            String l="请先选择Excil";
            return R.ok().put("l",l);
        }else{
            tPeopleService.saveBatch(array);
        }
        return R.ok();
    }

    /*
    * 拼接sql
    * */
    private String doSql(List<PeopleEntityForm> tPeopleEntityList,String flag){
       StringBuffer sqlString=new StringBuffer();
        if(tPeopleEntityList !=null){
          if("0".equals(flag)) {
              for (PeopleEntityForm tPeopleForm : tPeopleEntityList) {
                  if ("name".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else{
                          sqlString.append("and p.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }

                  }
                  if ("detachment".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and a1.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and a1.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("pdetachment".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and a2.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and a2.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("classesName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and b.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and b.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("sex".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.sex " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.sex " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("idcard".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.idcard " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.idcard " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("birthday".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.birthday " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.birthday " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("minName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and d.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and d.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("political".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.political " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.political " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("education".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.education " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.education " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("invitationHousehold".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.Invitation_household " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.Invitation_household " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("dutytime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.dutytime " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.dutytime " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("seniorityHistory".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.seniority_history " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.seniority_history " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("address".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.address " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.address " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("household".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.household " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.household " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("pdetachment".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and a2.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and a2.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("peopleCode".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.people_code " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.people_code " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("age".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.age " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.age " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("seniorityNow".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.seniority_now " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.seniority_now " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("seniorityTotal".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.seniority_total " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.seniority_total " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("educationTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.education_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.education_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("school".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.school " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.school " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("peopleType1".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.people_type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.people_type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("hight".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.hight " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.hight " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("cadre".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.cadre " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.cadre " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("poliTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.poli_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.poli_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("id".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.id " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.id " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("solo".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.solo " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.solo " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("isStudentSergeant".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.is_student_sergeant " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.is_student_sergeant " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("titleTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.title_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.title_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("dutyPostTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.duty_post_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.duty_post_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("zname".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and g.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and g.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("workidcard".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.workidcard " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.workidcard " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("gname".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and f.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and f.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("titleName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and m.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and m.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("oldName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.oldName " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.oldName " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("tecClass".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.tec_class " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.tec_class " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("blood".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.blood " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.blood " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("invitationHousehold".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.Invitation_household " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.Invitation_household " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("registerType".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.register_type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.register_type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("strength".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.strength " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.strength " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("callPhone".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.call_phone " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.call_phone " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("zdept".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("and p.zdept " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("and p.zdept " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
              }
          } else{
              for (PeopleEntityForm tPeopleForm : tPeopleEntityList) {
                  if ("name".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("detachment".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or a1.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or a1.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("pdetachment".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or a2.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or a2.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("classesName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or b.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or b.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("sex".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.sex " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.sex " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("idcard".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.idcard " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.idcard " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("birthday".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.birthday " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.birthday " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("minName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or d.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or d.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("political".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.political " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.political " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("education".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.education " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.education " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("invitationHousehold".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.Invitation_household " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.Invitation_household " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("dutytime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.dutytime " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.dutytime " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("seniorityHistory".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.seniority_history " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.seniority_history " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("address".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.address" + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.address " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("household".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.household " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.household " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("pdetachment".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or a2.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or a2.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("peopleCode".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.people_code " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.people_code " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("age".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.age " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.age " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("seniorityNow".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.seniority_now " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.seniority_now " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("seniorityTotal".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.seniority_total " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.seniority_total " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("educationTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.education_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.education_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("school".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.school " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.school " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("peopleType1".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.people_type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.people_type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("hight".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.hight" + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.hight " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("cadre".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.cadre " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.cadre " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("poliTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.poli_time" + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.poli_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("id".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.id  " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.id " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("solo".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.solo " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.solo " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("isStudentSergeant".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.is_student_sergeant " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.is_student_sergeant " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("titleTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.title_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.title_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("dutyPostTime".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.duty_post_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.duty_post_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("zname".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or g.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or g.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("workidcard".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.workidcard " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.workidcard " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("gname".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or f.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or f.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("titleName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or m.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or m.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("oldName".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.oldName " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.oldName " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("tecClass".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.tec_class" + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.tec_class " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("blood".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.blood " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.blood " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("invitationHousehold".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.Invitation_household " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.Invitation_household " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("registerType".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.register_type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.register_type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("strength".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.strength " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.strength " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("callPhone".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.call_phone " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.call_phone " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                  if ("zdept".equals(tPeopleForm.getFour())) {
                      if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                          sqlString.append("or p.zdept " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                      }else {
                          sqlString.append("or p.zdept " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                      }
                  }
                }
          }
        }


        return sqlString.toString();
    }



    /*
     *个人信息查询
     * */
    @RequestMapping("/findPeopleId")
    //   @RequiresPermissions("user:tpeople:list")
    public R findPeopleId(Integer peopleId){
        TPeopleEntity people = tPeopleService.findPeople(peopleId);
        return R.ok().put("people",people);

    }

    /*
     * 总队数据
     * */
    @RequestMapping("/totalCount")
    public R totalCount(@RequestBody statistisEntity peopleVo){
        List<PeopleVo> list = tPeopleService.totalCount(peopleVo);
        return R.ok().put("list",list);
    }


    /*
     * 历史总队
     * */
    @RequestMapping("/peopleAllHistory")
    public R peopleAllHistory(@RequestBody statistisEntity peopleVo){
        PeopleHistoryVo list = tPeopleService.peopleAllHistory(peopleVo);
        return R.ok().put("PeopleHistoryVo",list);
    }


    /*
     * 专职总队
     * */
    @RequestMapping("/findALLZZDept")
    public R findALLZZDept(@RequestBody statistisEntity peopleVo){
        PeopleZZVo list = tPeopleService.findALLZZDept(peopleVo);
        return R.ok().put("findALLZZDept",list);
    }



}
